<template>
  <div>
    <span style="font-size: 12px; color: gray">浏览量：{{ counter }}</span>
  </div>
</template>

<script>
export default {
  props: {
    id: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      counter: 0,
    }
  },

  methods: {
    async fetch() {
      const res = await this.$axios.$get('actions/browsers', {
        params: {
          query: {
            where: {
              name: 'browse',
              type: 'Course',
              object: this.id,
              forbiddenUser: true,
            },
          },
        },
      })
      this.counter = res.data.length
    },
  },

  created() {
    this.fetch()
  },
}
</script>

<style scoped lang="scss"></style>
